#!/bin/bash

while read line; do
    hashval=$(awk '{print $1}' <<< $line)
    size=$(awk '{print $3}' <<< $line)
    if (( size < 0 )); then
        size+="?"
    elif (( size < (1 << 10) )); then
        size="$(( size >> 0 ))B"
    elif (( size < (1 << 20) )); then
        size="$(( size >> 10 ))KB"
    elif (( size < (1 << 30) )); then
        size="$(( size >> 20 ))MB"
    elif (( size < (1 << 40) )); then
        size="$(( size >> 30 ))GB"
    fi
    echo $size $(git rev-list --objects --all | grep $hashval | awk '{print $2}')
done <<< $(git verify-pack -v .git/objects/pack/pack-*.idx | grep blob | sort -k 3 -n -r)
